package it;

import java.io.File;

import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Nodes;

public class Xml
{	
	public static void main(String[] args)
	{
		try
		{
			Builder parser = new Builder();
			Document doc = parser.build(new File("input.xml"));
			
			Nodes fields = doc.query("/fields/field");
			
			Element e1 = null;
			for(int i=0; i<fields.size(); i++)
			{
				if(fields.get(i) instanceof Element)
				{
					e1 = (Element) fields.get(i);
					
					Nodes attributes = e1.query("attribute");
					
					Element e2 = null;
					for(int j=0; j<attributes.size(); j++)
					{
						if(attributes.get(j) instanceof Element)
						{
							e2 = (Element) attributes.get(j);
							
							System.out.println(e2.getAttribute("type").getValue());
							System.out.println(e2.getAttribute("value").getValue());
						}
					}
				}
			}
			//Elements fields = root.getChildElements("field");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}